 package com.oanda.blackberry.ui;
 
 import net.rim.device.api.system.Bitmap;
 import net.rim.device.api.ui.ContextMenu;
 import net.rim.device.api.ui.Field;
 import net.rim.device.api.ui.FieldChangeListener;
 import net.rim.device.api.ui.Graphics;
 import net.rim.device.api.ui.component.CheckboxField;
 
 public class BitmapButtonField extends CheckboxField
 {
   int width;
   int height;
   Bitmap selected;
   Bitmap notSelected;
   boolean isSelected = false;
 
   public BitmapButtonField(Bitmap selected, Bitmap notSelected, String label, long style)
   {
     super(label, false, style);
     this.selected = selected;
     this.notSelected = notSelected;
     if (selected != null) {
       this.width = selected.getWidth();
       this.height = selected.getHeight();
     }
   }
 
   protected boolean keyChar(char key, int status, int time)
   {
     if (key == '\n') {
       if (getChangeListener() != null) {
         getChangeListener().fieldChanged(this, 0);
       }
       return true;
     }
     return super.keyChar(key, status, time);
   }
 
   public void paint(Graphics graphics)
   {
     if (this.isSelected) {
       if (this.selected != null) {
         graphics.drawBitmap(0, 0, this.width, this.height, this.selected, 0, 0);
       }
     }
     else if (this.notSelected != null)
       graphics.drawBitmap(0, 0, this.width, this.height, this.notSelected, 0, 0);
   }
 
   protected void layout(int maxWidth, int maxHeight)
   {
     setExtent(this.width, this.height);
   }
 
   public boolean isFocusable() {
     return true;
   }
 
   protected void onFocus(int direction)
   {
     super.onFocus(direction);
     this.isSelected = true;
     invalidate();
   }
 
   protected void onUnfocus() {
     super.onUnfocus();
     this.isSelected = false;
     invalidate();
   }
 
   protected void makeContextMenu(ContextMenu contextMenu)
   {
   }
}

